package cn.marinda.totipotentwar.global;

import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;
import java.util.List;
import java.util.Map;

/**
 * 抽象的游戏项目堆栈
 *
 * @author hwj
 * @date 2022/02/17
 */
public abstract class AbstractGameItemStack implements GameInventoryItemStack{
    protected Player player;
    protected GameData gameData;
    protected WeaponsData weaponsData;
    /**
     * 抽象的游戏项目堆栈
     *
     * @param player 球员
     */
    public AbstractGameItemStack(Player player){
        this.player = player;
    }

    /**
     * 抽象的游戏项目堆栈
     *
     * @param player   球员
     * @param gameData 游戏数据
     */
    public AbstractGameItemStack(Player player,GameData gameData,WeaponsData weaponsData){
        this.player = player;
        this.gameData = gameData;
        this.weaponsData = weaponsData;
    }


    /**
     * 抽象的游戏项目堆栈
     */
    public AbstractGameItemStack(){

    }


    /**
     * 通过集合物品堆拿到指定玩家
     *
     * @param itemStackList 项堆栈列表
     * @return {@link Player}
     */
    public Player indexItemStack(Map<Player,List<ItemStack>> playerItemStack,List<ItemStack> itemStackList){
        for(Player player : playerItemStack.keySet()){
            List<ItemStack> itemStacks = playerItemStack.get(player);
            if(itemStacks.equals(itemStackList)){
                 return player;
            }
        }
        return null;
    }

    /**
     * 让玩家物品堆栈
     *
     * @param player 球员
     * @return {@link List}<{@link ItemStack}>
     */
    public List<ItemStack> getPlayerItemStack(Map<Player,List<ItemStack>> playerItemStack,Player player){
        if(playerItemStack.containsKey(player)){
            return playerItemStack.get(player);
        }
        return null;
    }




}
